package com.example.springbatch_step_condition2;

public class Pizza {
    private String dough = "";  
    private String sauce = "";  
    private String topping = "";  
  
    public void setDough(String dough) { this.dough = dough; }  
    public void setSauce(String sauce) { this.sauce = sauce; }  
    public void setTopping(String topping) { this.topping = topping; }  
}  
  
abstract class PizzaBuilder {  
    protected Pizza pizza;  
  
    public Pizza getPizza() { return pizza; }  
    public void createNewPizzaProduct() { pizza = new Pizza(); }  
  
    public abstract void buildDough();  
    public abstract void buildSauce();  
    public abstract void buildTopping();  
}  
  
class HawaiianPizzaBuilder extends PizzaBuilder {  
    public void buildDough() { pizza.setDough("cross"); }  
    public void buildSauce() { pizza.setSauce("mild"); }  
    public void buildTopping() { pizza.setTopping("ham+pineapple"); }  
}  
  
class SpicyPizzaBuilder extends PizzaBuilder {  
    public void buildDough() { pizza.setDough("pan baked"); }  
    public void buildSauce() { pizza.setSauce("hot"); }  
    public void buildTopping() { pizza.setTopping("pepperoni+salami"); }  
}  
  
class Waiter {  
    private PizzaBuilder pizzaBuilder;  
  
    public void setPizzaBuilder(PizzaBuilder pb) { pizzaBuilder = pb; }  
    public Pizza getPizza() { return pizzaBuilder.getPizza(); }  
  
    public void constructPizza() {  
        pizzaBuilder.createNewPizzaProduct();  
        pizzaBuilder.buildDough();  
        pizzaBuilder.buildSauce();  
        pizzaBuilder.buildTopping();  
    }  
}  
  
 class BuilderPatternDemo {
    public static void main(String[] args) {
        Waiter waiter = new Waiter();
        PizzaBuilder hawaiianPizzaBuilder = new HawaiianPizzaBuilder();
        PizzaBuilder spicyPizzaBuilder = new SpicyPizzaBuilder();
        waiter.setPizzaBuilder(hawaiianPizzaBuilder);
        waiter.constructPizza(); // Builds a Hawaiian pizza  
        System.out.println(waiter.getPizza()); // Outputs: cross, mild, ham+pineapple  
        waiter.setPizzaBuilder(spicyPizzaBuilder);
        waiter.constructPizza(); // Builds a spicy pizza  
        System.out.println(waiter.getPizza());


    }

}
        // Outputs: pan baked, hot, pepperoni+salami     }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }  }